using System;
using System.Collections.Generic;
using DotNetNuke.Entities.Portals;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using dnneurope.portalgroups.logic;

namespace portalgroups.testing
{
    [TestClass]
    public class DotNetNukePortalGroupAdapterTests
    {
        [TestMethod]
        public void Save_PortalGroup_WithoutPortals_RaisesNoError()
        {
            //arrange
            PortalGroupController.RegisterInstance(new FakeController());
            var sut = new DotNetNukePortalGroupAdapter();

            var newGroup = new dnneurope.portalgroups.contract.PortalGroupInfo()
                {
                    AuthenticationDomain = "group.local",
                    PortalGroupId = -1,
                    PortalGroupName = "a group name",
                    MasterPortal = new dnneurope.portalgroups.contract.PortalInfo
                        {
                            PortalId = 1,
                            PortalName = "P"
                        }
                };
            //act
            var result = sut.Save(newGroup);
            //assert
            Assert.AreEqual(1, result);

        }

        class FakeController : IPortalGroupController
        {
            public int AddPortalGroup(PortalGroupInfo portalGroup)
            {
                portalGroup.PortalGroupId = 1;
                return portalGroup.PortalGroupId;
            }

            public void AddPortalToGroup(PortalInfo portal, PortalGroupInfo portalGroup, UserCopiedCallback callback)
            {
                throw new NotImplementedException();
            }

            public void DeletePortalGroup(PortalGroupInfo portalGroup)
            {
                throw new NotImplementedException();
            }

            public IEnumerable<PortalGroupInfo> GetPortalGroups()
            {
                throw new NotImplementedException();
            }

            public IEnumerable<PortalInfo> GetPortalsByGroup(int portalGroupId)
            {
                throw new NotImplementedException();
            }

            public void RemovePortalFromGroup(PortalInfo portal, PortalGroupInfo portalGroup, bool copyUsers, UserCopiedCallback callback)
            {
                throw new NotImplementedException();
            }

            public void UpdatePortalGroup(PortalGroupInfo portalGroup)
            {
                throw new NotImplementedException();
            }
        }
    }
}
